import 'package:flutter/material.dart';

class SettingsScreen extends StatelessWidget {
  const SettingsScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('设置页面'),
        leading: IconButton(
            icon: const Icon(Icons.arrow_back),
            onPressed: () => Navigator.pop(context)),
      ),
      body: ListView(
        padding: const EdgeInsets.all(16.0),
        children: [
          const Text(
            '应用设置',
            style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
          ),
          const SizedBox(height: 20),
          _buildSettingItem(
              icon: Icons.notifications, title: '通知设置', subtitle: '管理应用通知权限'),
          _buildSettingItem(
            icon: Icons.security,
            title: '隐私设置',
            subtitle: '管理您的隐私选项',
          ),
          _buildSettingItem(
            icon: Icons.language,
            title: '语言设置',
            subtitle: '更改应用语言',
          ),
          _buildSettingItem(
            icon: Icons.storage,
            title: '存储管理',
            subtitle: '管理缓存和数据存储',
          ),
          const SizedBox(height: 30),
          const Text('账户设置',
              style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold)),
          const SizedBox(height: 30),
          const SizedBox(height: 20),
          _buildSettingItem(
            icon: Icons.account_circle,
            title: '个人信息',
            subtitle: '更新您的个人资料',
          ),
          _buildSettingItem(
            icon: Icons.lock,
            title: '安全设置',
            subtitle: '更改密码和安全选项',
          ),
          _buildSettingItem(
            icon: Icons.payment,
            title: '支付设置',
            subtitle: '管理支付方式',
          ),
          const SizedBox(height: 40),
          Center(
            child: ElevatedButton(
              onPressed: () => Navigator.pop(context),
              style: ElevatedButton.styleFrom(
                backgroundColor: Colors.blue,
                foregroundColor: Colors.white,
                padding:
                const EdgeInsets.symmetric(horizontal: 40, vertical: 15),
              ),
              child: const Text('返回首页'),
            ),
          )
        ],
      ),
    );
  }
}

Widget _buildSettingItem({
  required IconData icon,
  required String title,
  required String subtitle,
}) {
  return ListTile(
    leading: Container(
        padding: const EdgeInsets.all(10),
        decoration: BoxDecoration(
          color: Colors.blue[50],
          borderRadius: BorderRadius.circular(10),
        ),
        child: Icon(icon, color: Colors.blue)),
    title: Text(title),
    subtitle: Text(subtitle),
    trailing: const Icon(Icons.arrow_forward_ios,size: 16),
    contentPadding: const EdgeInsets.symmetric(vertical: 8),
  );
}
